<template>
<div>
  <h1>hello vue-router</h1>
  <hr>
  <!--
    <RouterLink to="/home">首页</RouterLink><br>
    <RouterLink to="/list">列表</RouterLink>
  -->
  <button @click="goto('/home')">首页</button>
  <button @click="goto('/list')">列表</button>
  <hr>
  <RouterView></RouterView>
</div>
</template>

<script setup>
// 1. 引入 useRouter
import { useRouter } from 'vue-router'
// 2. 生成 router 对象
const router = useRouter()
const goto = (path) => {
  // 3. 使用 router对象进行跳转
  // router 相当于 this.$router
  router.push(path)
}

</script>




